<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# OPTIONS_GHC -fno-warn-orphans #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP, MagicHash, UnboxedTuples #-}</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 701
</span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-8"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Module      :  Control.Monad.STM</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2004</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Portability :  non-portable (requires STM)</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- Software Transactional Memory: a modular composable concurrency</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- abstraction.  See</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">--  * /Composable memory transactions/, by Tim Harris, Simon Marlow, Simon</span><span>
</span><span id="line-22"></span><span class="hs-comment">--    Peyton Jones, and Maurice Herlihy, in</span><span>
</span><span id="line-23"></span><span class="hs-comment">--    /ACM Conference on Principles and Practice of Parallel Programming/ 2005.</span><span>
</span><span id="line-24"></span><span class="hs-comment">--    &lt;https://www.microsoft.com/en-us/research/publication/composable-memory-transactions/&gt;</span><span>
</span><span id="line-25"></span><span class="hs-comment">--</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- This module only defines the 'STM' monad; you probably want to</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- import &quot;Control.Concurrent.STM&quot; (which exports &quot;Control.Monad.STM&quot;).</span><span>
</span><span id="line-28"></span><span class="hs-comment">--</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- Note that invariant checking (namely the @always@ and @alwaysSucceeds@</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- functions) has been removed. See ticket [#14324](https://ghc.haskell.org/trac/ghc/ticket/14324) and</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- the [removal proposal](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0011-deprecate-stm-invariants.rst).</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- Existing users are encouraged to encapsulate their STM operations in safe</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- abstractions which can perform the invariant checking without help from the</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- runtime system.</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Monad.STM</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier">STM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier">atomically</span></a></span><span class="hs-special">,</span><span class="hs-cpp">
#ifdef __GLASGOW_HASKELL__
</span><span>        </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#retry"><span class="hs-identifier">retry</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#orElse"><span class="hs-identifier">orElse</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>        </span><span class="annot"><a href="Control.Monad.STM.html#check"><span class="hs-identifier">check</span></a></span><span class="hs-special">,</span><span class="hs-cpp">
#endif
</span><span>        </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#throwSTM"><span class="hs-identifier">throwSTM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#catchSTM"><span class="hs-identifier">catchSTM</span></a></span><span>
</span><span id="line-48"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#ifdef __GLASGOW_HASKELL__
</span><span class="hs-cpp">#if ! (MIN_VERSION_base(4,3,0))
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.Conc</span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">catchSTM</span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Monad</span><span>    </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">MonadPlus</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Exception</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.html#"><span class="hs-identifier">GHC.Conc</span></a></span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#"><span class="hs-identifier">Control.Monad.Fix</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Sequential.STM</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#ifdef __GLASGOW_HASKELL__
</span><span class="hs-cpp">#if ! (MIN_VERSION_base(4,3,0))
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Applicative</span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Monad</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ap</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#endif
</span><span class="hs-cpp">

#ifdef __GLASGOW_HASKELL__
</span><span class="hs-cpp">#if ! (MIN_VERSION_base(4,3,0))
</span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">MonadPlus</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-75"></span><span>  </span><span class="hs-identifier">mzero</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">retry</span><span>
</span><span id="line-76"></span><span>  </span><span class="hs-identifier">mplus</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">orElse</span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Applicative</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-79"></span><span>  </span><span class="hs-identifier">pure</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">return</span><span>
</span><span id="line-80"></span><span>  </span><span class="hs-special">(</span><span class="hs-operator">&lt;*&gt;</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ap</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Alternative</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-83"></span><span>  </span><span class="hs-identifier">empty</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">retry</span><span>
</span><span id="line-84"></span><span>  </span><span class="hs-special">(</span><span class="hs-operator">&lt;|&gt;</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">orElse</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- | Check that the boolean condition is true and, if not, 'retry'.</span><span>
</span><span id="line-88"></span><span class="hs-comment">--</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- In other words, @check b = unless b retry@.</span><span>
</span><span id="line-90"></span><span class="hs-comment">--</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- @since 2.1.1</span><span>
</span><span id="line-92"></span><span class="annot"><a href="Control.Monad.STM.html#check"><span class="hs-identifier hs-type">check</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span id="check"><span class="annot"><span class="annottext">check :: Bool -&gt; STM ()
</span><a href="Control.Monad.STM.html#check"><span class="hs-identifier hs-var hs-var">check</span></a></span></span><span> </span><span id="local-6989586621679037673"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679037673"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679037673"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">() -&gt; STM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">STM ()
forall a. STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#retry"><span class="hs-identifier hs-var">retry</span></a></span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if ! (MIN_VERSION_base(4,3,0))
</span><span class="hs-comment">-- |Exception handling within STM actions.</span><span>
</span><span id="line-98"></span><span class="hs-identifier">catchSTM</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Exception</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-99"></span><span class="hs-identifier">catchSTM</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">STM</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">handler</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">catchSTM#</span><span> </span><span class="hs-identifier">m</span><span> </span><span class="hs-identifier">handler'</span><span>
</span><span id="line-100"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-101"></span><span>      </span><span class="hs-identifier">handler'</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">fromException</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-102"></span><span>                     </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">e'</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">handler</span><span> </span><span class="hs-identifier">e'</span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-identifier">m'</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">m'</span><span>
</span><span id="line-103"></span><span>                     </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">raiseIO#</span><span> </span><span class="hs-identifier">e</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-comment">-- | A variant of 'throw' that can only be used within the 'STM' monad.</span><span>
</span><span id="line-106"></span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- Throwing an exception in @STM@ aborts the transaction and propagates the</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- exception.</span><span>
</span><span id="line-109"></span><span class="hs-comment">--</span><span>
</span><span id="line-110"></span><span class="hs-comment">-- Although 'throwSTM' has a type that is an instance of the type of 'throw', the</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- two functions are subtly different:</span><span>
</span><span id="line-112"></span><span class="hs-comment">--</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- &gt; throw e    `seq` x  ===&gt; throw e</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- &gt; throwSTM e `seq` x  ===&gt; x</span><span>
</span><span id="line-115"></span><span class="hs-comment">--</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- The first example will cause the exception @e@ to be raised,</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- whereas the second one won\'t.  In fact, 'throwSTM' will only cause</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- an exception to be raised when it is used within the 'STM' monad.</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- The 'throwSTM' variant should be used in preference to 'throw' to</span><span>
</span><span id="line-120"></span><span class="hs-comment">-- raise an exception within the 'STM' monad because it guarantees</span><span>
</span><span id="line-121"></span><span class="hs-comment">-- ordering with respect to other 'STM' operations, whereas 'throw'</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- does not.</span><span>
</span><span id="line-123"></span><span class="hs-identifier">throwSTM</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Exception</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-124"></span><span class="hs-identifier">throwSTM</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">STM</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">raiseIO#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">toException</span><span> </span><span class="hs-identifier">e</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-keyword">data</span><span> </span><span id="STMret"><span class="annot"><a href="Control.Monad.STM.html#STMret"><span class="hs-identifier hs-var">STMret</span></a></span></span><span> </span><span id="local-6989586621679037689"><span class="annot"><a href="#local-6989586621679037689"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="STMret"><span class="annot"><a href="Control.Monad.STM.html#STMret"><span class="hs-identifier hs-var">STMret</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">State#</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">RealWorld</span></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679037689"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span id="local-6989586621679037692"><span class="annot"><a href="Control.Monad.STM.html#liftSTM"><span class="hs-identifier hs-type">liftSTM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037692"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">State#</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">RealWorld</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.STM.html#STMret"><span class="hs-identifier hs-type">STMret</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037692"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-131"></span><span id="liftSTM"><span class="annot"><span class="annottext">liftSTM :: forall a. STM a -&gt; State# RealWorld -&gt; STMret a
</span><a href="Control.Monad.STM.html#liftSTM"><span class="hs-identifier hs-var hs-var">liftSTM</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037669"><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, a #)
</span><a href="#local-6989586621679037669"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679037668"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037668"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, a #)
</span><a href="#local-6989586621679037669"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037668"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679037667"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037667"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679037666"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037666"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; a -&gt; STMret a
forall a. State# RealWorld -&gt; a -&gt; STMret a
</span><a href="Control.Monad.STM.html#STMret"><span class="hs-identifier hs-var">STMret</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037667"><span class="hs-identifier hs-var">s'</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037666"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-132"></span><span>
</span><span id="line-133"></span><span class="hs-comment">-- | @since 2.3</span><span>
</span><span id="line-134"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#MonadFix"><span class="hs-identifier hs-type">MonadFix</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-135"></span><span>  </span><span id="local-6989586621679037660"><span class="annot"><span class="annottext">mfix :: forall a. (a -&gt; STM a) -&gt; STM a
</span><a href="../../base/src/Control.Monad.Fix.html#mfix"><span class="hs-identifier hs-var hs-var hs-var hs-var">mfix</span></a></span></span><span> </span><span id="local-6989586621679037659"><span class="annot"><span class="annottext">a -&gt; STM a
</span><a href="#local-6989586621679037659"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; STM a
forall a. (State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="annot"><span class="annottext">((State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; STM a)
-&gt; (State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; STM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679037658"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037658"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-136"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679037657"><span class="annot"><span class="annottext">ans :: STMret a
</span><a href="#local-6989586621679037657"><span class="hs-identifier hs-var hs-var">ans</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STM a -&gt; State# RealWorld -&gt; STMret a
forall a. STM a -&gt; State# RealWorld -&gt; STMret a
</span><a href="Control.Monad.STM.html#liftSTM"><span class="hs-identifier hs-var">liftSTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; STM a
</span><a href="#local-6989586621679037659"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037656"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037658"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-137"></span><span>        </span><span class="annot"><a href="Control.Monad.STM.html#STMret"><span class="hs-identifier hs-type">STMret</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679037656"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037656"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STMret a
</span><a href="#local-6989586621679037657"><span class="hs-identifier hs-var">ans</span></a></span><span>
</span><span id="line-138"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">STMret a
</span><a href="#local-6989586621679037657"><span class="hs-identifier hs-var">ans</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="annot"><a href="Control.Monad.STM.html#STMret"><span class="hs-identifier hs-type">STMret</span></a></span><span> </span><span id="local-6989586621679037655"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037655"><span class="hs-identifier hs-var">s'</span></a></span></span><span> </span><span id="local-6989586621679037654"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037654"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679037655"><span class="hs-identifier hs-var">s'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037654"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-139"></span></pre></body></html>